const { User } = require('../../model/user');

module.exports = async (req, res) => {
    // 判断页面有没有id请求参数 如果有就是修改用户   如果没有就是注册用户
    if (req.query.id) {
        let user = await User.findOne({_id: req.query.id});
        let { id, message} = req.query;
        res.render('admin/user-edit', {
            user,
            id,
            message,
            path: '/admin/user-modify?id=' + req.query.id
            });
    } else {
        let {message} = req.query;
        res.render('admin/user-edit', {
        message: message,
        path: '/admin/user-edit'
        });
    }
};